<!--看板>今日最低-->
<template>
     <div class="card rdsp-card-view realSafety-page" data-page="realSafety">
        <div class="card-content rank-content">
            <div class="realSafety-rdsp-card-top">
                <div class="circle-list" @click="showRistList(3)">
                    <a href="/unitSafetyExponentMore/" data-view=".view-main">
                        <div class="rdsp-card-circle three">
                            <i class="iconfont icon-huo three"></i>
                        </div>
                        <span id="realSafety_risk_count_{{getNewId}}">0</span>
                        <p>告急单位</p>
                    </a>
                </div>
                <div class="circle-list" @click="showRistList(2)">
                    <a href="/unitSafetyExponentMore/" data-view=".view-main">
                        <div class="rdsp-card-circle two">
                            <i class="iconfont icon-huo1 two"></i>
                        </div>
                        <span id="realSafety_danger_count_{{getNewId}}">0</span>
                        <p>危险单位</p>
                    </a>
                </div>
                <div class="circle-list" @click="showRistList(1)">
                    <a href="/unitSafetyExponentMore/" data-view=".view-main">
                        <div class="rdsp-card-circle one">
                            <i class="iconfont icon-gongandunpai one"></i>
                        </div>
                        <span id="realSafety_safe_count_{{getNewId}}">0</span>
                        <p>安全单位</p>
                    </a>
                </div>
            </div>
            <div class="realSafety-card-bottom card-content-padding build-bg-gray">
                <a href="/unitSafetyExponentMore/" data-view=".view-main">
                    <div class="left-title" @click="showRistList(0)">低分单位</div>
                </a>
                <div class="rdsp-card-con">
                    <div class="realSafety-left-last">
                        <div class="left">
                            <div class="l" id="lastImg_{{getNewId}}"></div>
                            <div class="r">
                                <span>
                                    <p class="number" id="lastScore_{{getNewId}}">0<span>分</span></p>
                                    <p class="text" id="lastUnit_{{getNewId}}">-</p>
                                </span>
                            </div>
                        </div>
                        <div class="right">
                            <div class="realSafety" id="safetContent_{{getNewId}}"></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    return {
        mounted() {
            var self = this;
            
        },
        data: function () {
            return {
                list:[],
                getNewId: (new Date()).getTime()
            }
        },
        methods: {
            showRistList:function(type){
              app.router.navigate("/unitSafetyExponentMore/"+type+"/");
            },
            getUnitSafety: function () {
                var self = this;
                var $ = self.$$;
                $("#safetContent_" + self.getNewId).empty();
                $("#lastImg_" + self.getNewId).empty();
                Dao.getSafeStatusForOrgCount({
                    userName: userInfor.accountName,
                    deviceId: appKeyObj.deviceId,
                    orgIds: self.id_org,
                    fireType:-1
                },function (data) {
                    if(data){
                        for(var i=0;i<data.length;i++){
                            if(data[i].safeCategory==1){
                                $("#realSafety_safe_count_" + self.getNewId).empty().html(data[i].orgCount);
                            }
                            if(data[i].safeCategory==2){
                                $("#realSafety_danger_count_" + self.getNewId).empty().html(data[i].orgCount);
                            }
                            if(data[i].safeCategory==3){
                                $("#realSafety_risk_count_" + self.getNewId).empty().html(data[i].orgCount);
                            }
                        }
                    }
                },true);
                Dao.getSafetyOrgList({
                    userName: userInfor.accountName,
                    deviceId: appKeyObj.deviceId,
                    orgIds:self.id_org,
                    queryType:0,
                    pageIndex:0,
                    pageSize:3,
                },function (data) {
                    self.list=data;
                    self.datalist(data);
                },true);
            },
            datalist: function (data) {
                let self = this;
                for (var i = 0; i < data.length && i < 5; i++) {
                    if(i==0){
                        $("#lastImg_" + self.getNewId).append(`<img orgId="` + common.transNullundefined(data[i].orgId) + `" orgName="` + common.transNullundefined(data[i].orgName) + `" src="` + transLogo(data[i].orgLogoUrl) + `">`);
                        $("#lastScore_" + self.getNewId).html(data[i].score).css('color',getTextColorByScore(data[i].score,1));
                        $("#lastUnit_" + self.getNewId).html(data[i].orgName);
                    }

                    $("#safetContent_" + self.getNewId).append(`<img orgId="` + common.transNullundefined(data[i].orgId) + `" orgName="` + common.transNullundefined(data[i].orgName) + `" src="` + transLogo(data[i].orgLogoUrl) + `">`);
                }
                //左边的
                jQuery("#lastImg_" + self.getNewId + " img").click(function(){
                    single_Orgid = jQuery(this).attr("orgId");
                    single_OrgName = jQuery(this).attr("orgName");
                    //调用首页方法
                    // app.view.get("#home").router.currentPageEl.f7Component.loadSingle();
                    app.router.navigate("/soleKanban/");
                });
                //右边的
                jQuery("#safetContent_" + self.getNewId + " img").click(function(){
                    single_Orgid = jQuery(this).attr("orgId");
                    single_OrgName = jQuery(this).attr("orgName");
                    //调用首页方法
                    // app.view.get("#home").router.currentPageEl.f7Component.loadSingle();
                    app.router.navigate("/soleKanban/");
                });
            },
        },
        on: {
            pageAfterIn: function(e, page) {
                var self = this;
                if (single_Orgid == "") {
                    self.id_org = userInfor.organizationIds;
                } else {
                    self.id_org = single_Orgid;
                }
                self.getUnitSafety();//获取单位实时安全指数
            },
        }
    }
</script>
